/**
 * @Author: YangYun
 * @Date: 2020/4/14 9:30
 */
package main

import (
    "context"
    "git.900sui.cn/kc/kcgin"
    "git.900sui.cn/kc/kcgin/logs"
    "git.900sui.cn/kc/rabbitmq"
    "git.900sui.cn/kc/rpcinterface/client/elastic/bus"
    "github.com/streadway/amqp"
    "strconv"
)

func main() {
    logs.Info("Environment Variable:MSF_ENV:",kcgin.KcConfig.RunMode)

    rpcEsMemer := new(bus.Member).Init()
    defer rpcEsMemer.Close()

    err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("queue.busMemberAddToEs"), func(msg amqp.Delivery)  {
        memberId,err := strconv.Atoi(string(msg.Body))
        if err != nil {
            return
        }
        reply := false
        if err := rpcEsMemer.AddMember(context.Background(), &memberId, &reply); err != nil {
            return
        }
        return
    })
    if err != nil {
        panic(err)
    }
}